
<template>
<div style="padding: 10px;">
        <el-form
          :model="queryParams"
          ref="queryForm"
          class="queryForm"
          :inline="true"
          v-show="showSearch" @submit.native.prevent
          
          >
    
            <el-form-item label="登录用户名"
                          desc="登录用户名"
                          prop="userName">
                <el-input
                        v-model.trim="queryParams.userName"
                        placeholder="登录用户名"
                        clearable
                        size="small"
                        style="width:120px;"
                        @keyup.enter.native="handleQuery"
                />
            </el-form-item>
    
    
            <!--       <el-form-item label="最近一次登录IP"
                   desc="最近一次登录IP"
                    prop="lastIp">
                                     <el-input
                                     v-model.trim="queryParams.lastIp"
                                     placeholder="最近一次登录IP"
                                     clearable
                                     size="small"
                                     style="width:120px;"
                                     @keyup.enter.native="handleQuery"
                                     />
                               </el-form-item>-->

             
        

            
             
            
                       <!-- <el-form-item label="最近登录时间"
                        desc="最近登录时间"
                         prop="lastLoginTime">
                                          <el-input
                                          v-model.trim="queryParams.lastLoginTime"
                                          placeholder="最近登录时间"
                                          clearable
                                          size="small"
                                          style="width:120px;"
                                          @keyup.enter.native="handleQuery"
                                          />
                                    </el-form-item>-->

             
        

            
             
            <!--
                        <el-form-item label="IP锁定可支持多个IP用逗号隔开"
                        desc="IP锁定可支持多个IP用逗号隔开"
                         prop="ip">
                                          <el-input
                                          v-model.trim="queryParams.ip"
                                          placeholder="IP锁定可支持多个IP用逗号隔开"
                                          clearable
                                          size="small"
                                          style="width:120px;"
                                          @keyup.enter.native="handleQuery"
                                          />
                                    </el-form-item>-->

             
        

            
             
            <!--
                        <el-form-item label="ip锁定状态[查询]0未锁定1己锁定"
                        desc="ip锁定状态[查询]0未锁定1己锁定"
                         prop="ipState">
                                          <el-input
                                          v-model.trim="queryParams.ipState"
                                          placeholder="ip锁定状态[查询]0未锁定1己锁定"
                                          clearable
                                          size="small"
                                          style="width:120px;"
                                          @keyup.enter.native="handleQuery"
                                          />
                                    </el-form-item>-->

             
        

            
             
            
                        <el-form-item label="是否为超级管理员"
                        desc="是否为超级管理员[查询]"
                         prop="isAdmin">
                                          <el-input
                                          v-model.trim="queryParams.isAdmin"
                                          placeholder="是否为超级管理员[查询]"
                                          clearable
                                          size="small"
                                          style="width:120px;"
                                          @keyup.enter.native="handleQuery"
                                          />
                                    </el-form-item>

             
        

            
             
            
                     <!--   <el-form-item label="在线状态[数据字典=OnlieState]"
                        desc="在线状态[数据字典=OnlieState]"
                         prop="onlieState">
                                          <el-input
                                          v-model.trim="queryParams.onlieState"
                                          placeholder="在线状态[数据字典=OnlieState]"
                                          clearable
                                          size="small"
                                          style="width:120px;"
                                          @keyup.enter.native="handleQuery"
                                          />
                                    </el-form-item>-->

             
        

            
             
            
                        <el-form-item label="账号状态"
                        desc="账号状态[数据字典=AccountState]  1正常  5己停用"
                         prop="state">
                             <dic-select
                                          v-model="queryParams.state"
                                          :code="dicInner.sys_account_state"
                                          placeholder="账号状态[数据字典=AccountState]  1正常  5己停用"
                                          clearable
                                          size="small"
                                          style="width:120px;"
                                          @keyup.enter.native="handleQuery"
                                          />
                                    </el-form-item>

           
        

            
             
            
                  <!--      <el-form-item label="累计登录次数"
                        desc="累计登录次数"
                         prop="loginNum">
                                          <el-input
                                          v-model.trim="queryParams.loginNum"
                                          placeholder="累计登录次数"
                                          clearable
                                          size="small"
                                          style="width:120px;"
                                          @keyup.enter.native="handleQuery"
                                          />
                                    </el-form-item>-->

             
        

            
             <!--
            
                        <el-form-item label="登录密码"
                        desc="登录密码"
                         prop="passWord">
                                          <el-input
                                          v-model.trim="queryParams.passWord"
                                          placeholder="登录密码"
                                          clearable
                                          size="small"
                                          style="width:120px;"
                                          @keyup.enter.native="handleQuery"
                                          />
                                    </el-form-item>
-->
          
        

          
          
       
        

          
          
          
          
          
        

          

        
          <el-form-item>
            <el-button
              type="primary"
              icon="el-icon-search"
              size="mini"
              @submit.native.prevent
              @click="handleQuery">搜索
            </el-button>
            <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置
            </el-button>
          </el-form-item>
        </el-form>




     <el-row :gutter="10" class="mb8">
            <el-col :span="1.5" class="buttonsRow">
                            <el-button type="primary" size="small" plain  @click="()=>triggerModify()" >新增</el-button>
            </el-col>
            <right-toolbar
            @layout="(_obj)=>columnsHidden=_obj"
            :showSearch.sync="showSearch"
            @queryTable="getInfoList"
            ></right-toolbar>
      </el-row>


      <section class="tablecontainer">
    <el-table
      border
      ref="multipleTable"
      :data="dataList"
      size="mini"
      class="tabletop"
      tooltip-effect="dark"
      style="width: 100%"
      @selection-change="rows=>{
         selectRows=rows
      }"
      @row-click="row=>{
          tableRowClickOnece(row,'multipleTable')
      }"
      :row-class-name="tableRowClassName"
    >

       <el-table-column
        type="selection"
        width="40"
        align="center"
        >
      </el-table-column>

       <el-table-column
            label="操作" width="55" align="center">
            <template slot-scope="scope">

                        <el-popover
                        placement="top-start"
                        title="操作"
                        width="222"
                        trigger="hover"
                        >

                    <div>
                             <el-button size="mini" type="text" icon="el-icon-edit" @click="()=>triggerModify(scope.row)">
                              修改
                              </el-button>

                              <el-button size="mini" type="text" icon="el-icon-notebook-1" @click="()=>openLog(scope.row)">变更日志
                              </el-button>

                              <el-button size="mini" type="text" icon="el-icon-delete" @click="()=>handleDelete(scope.row)">删除
                              </el-button>
                    </div>
                        <el-button slot="reference" type="text">操作</el-button>
             </el-popover>

          
            </template>
          </el-table-column>

      
       
<!--     <el-table-column
                   v-if="!columnsHidden['lastIp']"
                                          label="最近一次登录IP" prop="lastIp"  min-width="120px;">
                              <template slot-scope="scope">
                              <div>
                                    {{scope.row.lastIp}}
                              </div>
                              </template>
                              </el-table-column>
    -->
    
    
        <el-table-column
                v-if="!columnsHidden['userName']"
                label="登录用户名" prop="userName"  min-width="120px;">
            <template slot-scope="scope">
                <div>
                    {{scope.row.userName}}
                </div>
            </template>
        </el-table-column>
        
       
<!--
     <el-table-column
                   v-if="!columnsHidden['lastLoginTime']"
                                          label="最近登录时间" prop="lastLoginTime"  min-width="120px;">
                              <template slot-scope="scope">
                              <div>
                                    {{scope.row.lastLoginTime}}
                              </div>
                              </template>
                              </el-table-column>
-->





<!--     <el-table-column
                   v-if="!columnsHidden['ip']"
                                          label="IP锁定可支持多个IP用逗号隔开" prop="ip"  min-width="120px;">
                              <template slot-scope="scope">
                              <div>
                                    {{scope.row.ip}}
                              </div>
                              </template>
                              </el-table-column>-->

          
          
      
       
<!--     <el-table-column
                   v-if="!columnsHidden['ipState']"
                                          label="ip锁定状态[查询]0未锁定1己锁定" prop="ipState"  min-width="120px;">
                              <template slot-scope="scope">
                              <div>
                                    {{scope.row.ipState}}
                              </div>
                              </template>
                              </el-table-column>

          -->
          
      
       
     <el-table-column
                   v-if="!columnsHidden['isAdmin']"
                                          label="超级管理员" prop="isAdmin"  min-width="120px;">
                              <template slot-scope="scope">
                              <div>
                                    {{scope.row.isAdmin==5?'管理':'普通'}}
                              </div>
                              </template>
                              </el-table-column>

          
          
      
       
<!--
     <el-table-column
                   v-if="!columnsHidden['onlieState']"
                                          label="在线状态[数据字典=OnlieState]" prop="onlieState"  min-width="120px;">
                              <template slot-scope="scope">
                              <div>
                                    {{scope.row.onlieState}}
                              </div>
                              </template>
                              </el-table-column>
-->

          
          
      
       
              <el-table-column
                              v-if="!columnsHidden['state']"
                                          label="账号状态" prop="state"  min-width="120px;">
                              <template slot-scope="scope">
                              <dic-tag :code="dicInner.sys_account_state"
                               v-model="scope.row.state"
                              >
                              </dic-tag>
                              </template>
                              </el-table-column>


         
          
      
       
<!--
     <el-table-column
                   v-if="!columnsHidden['loginNum']"
                                          label="累计登录次数" prop="loginNum"  min-width="120px;">
                              <template slot-scope="scope">
                              <div>
                                    {{scope.row.loginNum}}
                              </div>
                              </template>
                              </el-table-column>
-->

   
   
   
   <!--
     <el-table-column
                   v-if="!columnsHidden['passWord']"
                                          label="登录密码" prop="passWord"  min-width="120px;">
                              <template slot-scope="scope">
                              <div>
                                    {{scope.row.passWord}}
                              </div>
                              </template>
                              </el-table-column>-->

          
          
      
       


          
          
      
       
           
          
      


      
          <el-table-column
            label="添加时间/人" prop="add_time/add_user" v-if="!columnsHidden['add_time/add_user']">
            <template slot-scope="scope">
              <span>{{scope.row.addTime|dateFormatYYYYMMDD}}/{{scope.row.addUser}}</span>
            </template>
          </el-table-column>

          <el-table-column
            label="更新时间/人" prop="lastEditTime/editUser" v-if="!columnsHidden['lastEditTime/editUser']">
            <template slot-scope="scope">
              <span>{{scope.row.lastEditTime|dateFormatYYYYMMDD}}/{{scope.row.editUser}}</span>
            </template>
          </el-table-column>


         



    </el-table>


      <el-pagination
          :background="true"
          style="padding: 20px;"
          :current-page.sync="queryParams.pageNum"
          :page-size="queryParams.pageSize"
          layout="prev, pager, next"
          :total="total"
          @size-change="(pageSize)=>{$data.queryParams.pageSize=pageSize;dataList=[];getInfoList();}"
          @current-change="(pageNum)=>{$data.queryParams.pageNum=pageNum;dataList=[];getInfoList();}"
        >
        </el-pagination>


       </section>
</div>


</template>

<script>
  import { formData, formMethod, PageData } from '@/utils/formcommon';
  import { getUrlParam,dateFormatYYYYMMDD } from '@/utils/index';
  import {default as FormDialog} from '@codegenarate/mydialogplus'

  import  * as  api  from '@/apis/sysAccount.api.js';

      const dicInner={
            
             "___sys_account_serverNumber":"服务器编号ID",
              "sys_account_serverNumber":"sys_account_serverNumber",
            
             "___sys_account_lastEditTime":"最近更新时间",
              "sys_account_lastEditTime":"sys_account_lastEditTime",
            
             "___sys_account_editUserId":"最近更新人ID",
              "sys_account_editUserId":"sys_account_editUserId",
            
             "___sys_account_editUser":"最近更新人",
              "sys_account_editUser":"sys_account_editUser",
            
             "___sys_account_addTime":"添加时间",
              "sys_account_addTime":"sys_account_addTime",
            
             "___sys_account_addUserId":"添加人ID",
              "sys_account_addUserId":"sys_account_addUserId",
            
             "___sys_account_addUser":"添加人",
              "sys_account_addUser":"sys_account_addUser",
            
             "___sys_account_delState":"有效状态[数据字典=del_state] 1有效  5删除",
              "sys_account_delState":"sys_account_delState",
            
             "___sys_account_tenantId":"租户ID",
              "sys_account_tenantId":"sys_account_tenantId",
            
             "___sys_account_tenantType":"租户类型 1应用管理者2应用消息者",
              "sys_account_tenantType":"sys_account_tenantType",
            
             "___sys_account_lastIp":"最近一次登录IP",
              "sys_account_lastIp":"sys_account_lastIp",
            
             "___sys_account_lastLoginTime":"最近登录时间",
              "sys_account_lastLoginTime":"sys_account_lastLoginTime",
            
             "___sys_account_ip":"IP锁定可支持多个IP用逗号隔开",
              "sys_account_ip":"sys_account_ip",
            
             "___sys_account_ipState":"ip锁定状态[查询]0未锁定1己锁定",
              "sys_account_ipState":"sys_account_ipState",
            
             "___sys_account_isAdmin":"是否为超级管理员[查询]",
              "sys_account_isAdmin":"sys_account_isAdmin",
            
             "___sys_account_onlieState":"在线状态[数据字典=OnlieState]",
              "sys_account_onlieState":"sys_account_onlieState",
            
             "___sys_account_state":"账号状态[数据字典=AccountState]  1正常  5己停用",
              "sys_account_state":"sys_account_state",
            
             "___sys_account_loginNum":"累计登录次数",
              "sys_account_loginNum":"sys_account_loginNum",
            
             "___sys_account_passWord":"登录密码",
              "sys_account_passWord":"sys_account_passWord",
            
             "___sys_account_userName":"登录用户名",
              "sys_account_userName":"sys_account_userName",
            
             "___sys_account_id":"主键ID",
              "sys_account_id":"sys_account_id",
              
      }

  export default {
    name: 'sysAccountlist',
    data() {
      return {
        api: api,
        dicInner,
        ...formData,
        queryParams: {
          name: '',
          searchKey:'',
            
            "serverNumber":'',
            
            "lastEditTime":'',
            
            "editUserId":'',
            
            "editUser":'',
            
            "addTime":'',
            
            "addUserId":'',
            
            "addUser":'',
            
            "delState":'',
            
            "tenantId":'',
            
            "tenantType":'',
            
            "lastIp":'',
            
            "lastLoginTime":'',
            
            "ip":'',
            
            "ipState":'',
            
            "isAdmin":'',
            
            "onlieState":'',
            
            "state":'',
            
            "loginNum":'',
            
            "passWord":'',
            
            "userName":'',
            
            "id":'',
            
          ...PageData,
        },
        lists: [],
        selectRows: [],
        classId: '',
        classIdPath: '',
        className: '',
        loading: false,
        isFold: false,
        tableRowClassName({ row, rowIndex }) {
            if (row.rowType == 'total') {
            return 'total-row';
            }
             return '';
         },
      };
    },
    components: {
      svgIcon:()=>import('@codegenarate/svg-icon'),
      dicSelect: () => import('@/components/dicselect.vue'),
      dicTag: () => import('@/components/DicSelect/dic-tag.vue'),
      RightToolbar: () => import('@/components/RightToolbar/index.vue'),
      modify: () => import('./SysAccountModify.vue'),
    },
    mounted() {
        if(this.$props['immediate']){
        this.getInfoList();
        }
    },
    filters: {
      dateFormatYYYYMMDD:dateFormatYYYYMMDD,
     },
    computed: {
    },
    watch:{},
    props:{
      immediate: {
            type: [Boolean],
            default() {
              return true;
            },
          },
    },
    methods: {
      ...formMethod,
       /**
     * @description:
     * @params _data.dataList
     * @return
     */
    initByDialog(_data) {
      this.dataList = _data && _data.dataList || [];
    },
      tableRowClickOnece(row, tableRef, options) {
            var table = this.$refs[tableRef];
            if (options && options.canSelect) {
                  var istrue = options.canSelect(row);
                  if (!istrue) {
                  table && table.toggleRowSelection(row,false);
                  }
            }
            table && table.clearSelection();
            table && table.toggleRowSelection(row);
    },
       async triggerModify(row) {
      var result = await FormDialog({
            width:'888px',
        title: row&&row.id ? '编辑【账号】' : '新增【账号】',
        data() {
          return { ...row };
        },
        components: {
          modify: () => import('./SysAccountModify.vue'),
        },
      });
      if (!(result && result.success)) {
        return result;
      }
      this.getInfoList();
    },

    },
  };
</script>
